
import { Message, MessageBox } from 'element-ui'

export const tableColumn = (edit, del) => {
    const table = {
        index: true,
        tr : [
            {
                label: "项目名",
                prop: "name"
            },
            {
                label: "主管",
                prop: "user_name"
            },
            {
                label: "时间",
                prop: "create_time"
            },
            {
                el: 'button',
                label: '操作',
                btns: [
                    {
                        text: '编辑',
                        func: row => {
                            edit(row)
                        }
                    },
                    {
                        text: '删除',
                        type: 'danger',
                        func: async row => {
                            try {
                                let res = await MessageBox.confirm('确认删除吗？')
                                if (res == 'confirm') {
                                    del(row)
                                }
                            } catch (error) {
                                console.log(error, 'error')
                            }
                        }
                    }
                ]
            }
        ]
    }
    return table;
}
